import request from '../utils/request.js'
// 向外暴露
export function login(data){
  return request({
    method:'POST',
    url:'/v1_0/authorizations',
    data
  })
}

export function sendSms(data){
  return request({
    method:'GET',
    url:`/v1_0/sms/codes/${data}`,
  })
}

export function getUserInfo(){
  return request({
    method:'GET',
    url:'/v1_0/user',
/*     headers:{
      // 注意：该接口需要授权才能访问，token的数据格式：Bearer token数据，注意 Bearer 后面有个空格
      Authorization: `Bearer ${store.state.user.token}`
    } */
  })
}
export function getUserChannels(){
  return request({
    method:'GET',
    url:'/v1_0/user/channels'
  })
}

export function getAllChannels(){
  return request({
    method:'GET',
    url:'/v1_0/channels'
  })
}

export function addUserChannels(channel){
  return request({
    method:'PATCH',
    url:'/v1_0/user/channels',
    data:{
      channels:[channel]
    }
  })
}

// 删除用户频道
export function deleteUserChannel(channelId){
  return request({
    method:'DELETE',
    url:`/v1_0/user/channels/${channelId}`,
  })
}

//添加关注
export function addfollowings(target){
  return request({
    method:'post',
    url:'/v1_0/user/followings',
    data:{
      target
    }
  })
}
//取消关注
export function delfollowings(target){
  return request({
    method:'DELETE',
    url:`/v1_0/user/followings/${target}`
  })
}

//获取用户的基本信息
export function getUseredit(){
  return request({
    method:'get',
    url:'/v1_0/user/profile'
  })
}

// 更新用户资料
export const updateUserprofile = data => {
 return request({
   method: 'PATCH',
   url: '/v1_0/user/profile',
   data
 })
}
// 更新用户资料
export const updateUserphoto = data => {
  return request({
    method: 'PATCH',
    url: '/v1_0/user/photo',
    data
  })
 }